<?php

namespace app\common\service;

class ConstantOrderService
{
    // UNPAID    PARTIALLY_SHIPPING   AWAITING_SHIPMENT   AWAITING_COLLECTION  IN_TRANSIT   DELIVERED   COMPLETED  CANCELLED
    /**
     *  订单状态=>未支付
     */
    public static $status_unpaid = 'UNPAID';

    /**
     *  订单状态=>暂停中
     */
    public static $status_on_hold = 'ON_HOLD';

    /**
     *  订单状态=>部分发货
     */
    public static $status_partially_shipping = 'PARTIALLY_SHIPPING';
    /**
     *  订单状态=>待发货
     */
    public static $status_awaiting_shipment = 'AWAITING_SHIPMENT';

    /**
     *  订单状态=>等待揽收
     */
    public static $status_awaiting_collection = 'AWAITING_COLLECTION';

    /**
     *  订单状态=>运输中
     */
    public static $status_in_transit = 'IN_TRANSIT';

    /**
     *  订单状态=>已收货
     */
    public static $status_delivered = 'DELIVERED';

    /**
     *  订单状态=>已完成
     */
    public static $status_completed = 'COMPLETED';

    /**
     *  订单状态=>已取消
     */
    public static $status_cancelled = 'CANCELLED';

    /**
     *  预发货状态=>未发货
     */
    public static $ship_status_unshipped = 0;
    /**
     *  预发货状态=>排队发货中
     */
    public static $ship_status_waiting = 1;
    /**
     *  预发货状态=>发货异常
     */
    public static $ship_status_error = 2;
    /**
     *  预发货状态=>发货成功,回传物流单号
     */
    public static $ship_status_sendnum = 3;
    /**
     *  预发货状态=>物流单号完成，发货成功
     */
    public static $ship_status_success = 4;
    /**
     *  预发货状态=>等待海外仓跟踪号
     */
    public static $ship_status_waiting_seanum = 5;
    /**
     *  预发货状态=>结束发货
     */
    public static $ship_status_completed = 6;

    /**
     * 订单状态
     */
    public static function getStatus($id = '', $isarray = false)
    {
        $array = [
            self::$status_unpaid   => '未支付',
            self::$status_on_hold   => '暂停中',
            self::$status_partially_shipping  => '部分发货',
            self::$status_awaiting_shipment  => '等待发货',
            self::$status_awaiting_collection  => '等待揽收',
            self::$status_in_transit  => '运输中',
            self::$status_delivered  => '已交付',
            self::$status_completed  => '已完成',
            self::$status_cancelled  => '已关闭',
        ];
        return $isarray ? $array : (isset($array[$id]) ? $array[$id] : '');
    }
}